﻿<?
class DatabaseConnection{
	
	private $db = null;
	public $host;
	public $dbUser;
	public $dbPass;
	public $dbName;
	
	public static function GetDbcontroller()
	{
		global $db;
		if($db == null)
			$db = new DatabaseConnection();
		return $db;
	}
	
	public function OpenConnection()
	{
		$con = @mysql_connect($this->host,$this->dbUser,$this->dbPass);
		
		if (!$con) 
			return false;
		else
		{
			@mysql_select_db($this->dbName, $con );
			@mysql_query(@"SET character_set_results = utf8,
				character_set_client = utf8,
				character_set_connection = utf8,
				character_set_database = utf8,
				character_set_server = utf8", $con);
				//mysql_query("SET NAMES UTF8");
				//mysql_query("SET character_set_results=utf8");
				//mysql_query("SET character_set_client=utf8");
				//mysql_query("SET character_set_connection=utf8");
			//$set = "SET character_set_results=utf8"; 
			//@mysql_query($set) or die('Invalid query: ' . mysql_error()); 
			return true;
		}
	}
	
	public function Exec($queryString)
	{
		$sql = @mysql_query($queryString);
		return $sql;
	}
	/*
	public function OpenConnection()
	{
		@mysql_close();
	}*/
}
?>